package com.hippo.core.vm

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.hippo.core.respository.ApiRepository
import com.hippo.core.state.ResetPwdState
import com.hippo.core.utils.UiHandler.showToast
import kotlinx.coroutines.launch

class ResetPasswordVM :ViewModel() {




    fun resetPassword(params: ResetPwdState) {
        viewModelScope.launch {
            ApiRepository.resetPassword(params)
                .onSuccess {
                    showToast("重置成功")
                }
                .onFailure {
                    showToast(it.msg.orEmpty())
                }
        }
    }





    fun sendEmailCode(email:String) {
        viewModelScope.launch {
            ApiRepository.sendEmailCode(email,"2")
                .onSuccess {
                    showToast("发送成功")
                }
                .onFailure {
                    showToast(it.msg.orEmpty())
                }
        }
    }



}